[#import "/framework/JGP.htm"  as JGP]
<!--
项目   jgp-cloud-parent
作者   LOUFEI [Gavin]
时间   2019-11-03
-->
[@JGP.head "编辑角色"/]
[@JGP.body]
    <jgp-div _row="['40','*']" _runit="px">
        <div slot="1-1">
            <jgp-btn _fn="saveCallback" _form="form">保存</jgp-btn>
        </div>
        <jgp-panel slot="2-1">
            <jgp-form _id="form" _action="/security/role-api-ctl/save" _cols="12" _label_width="80px">
                <jgp-text _name="name" _col="12" _label="角色名" _placeholder="角色名" _required="true"></jgp-text>
                <jgp-text _name="icon" _col="6" _label="图标" _required="true"></jgp-text>
                <jgp-num _name="sort" _col="6" _required="true" _label="排序" _value="0"></jgp-num>
                <jgp-area _name="remark" _col="12" _label="说明"></jgp-area>
            </jgp-form>
        </jgp-panel>
    </jgp-div>
[/@JGP.body]

[@JGP.foot]

    <script>
        var id = ${id!'null'};
        var parentId = ${parentId!'null'};

        JGP.$onload(function () {
            initRole();
        })

        function initRole() {
            if (id) {
                JGP.$post('/security/role-api-ctl/query-one', {id: id}, function (res) {
                    JGP.form('form').setData(res.data.role)
                })
            } else if (parentId !== null) {
                JGP.form('form').field('parentId', parentId)
            }
        }

        function saveCallback(result) {
            if (result.back.flag) {
                JGP.$alert('保存成功')
                JGP.$close(true);
            }
        }

    </script>

[/@JGP.foot]